-
TSQL equivalent of "Eval"?
Hello all,
Does anyone know if there's a TSQL function that acts like a JavaScript eval? What I'd like to do is declare some of my SQL code as text variables and then use that code later by referencing that variable. Is there a way to do this?
-
TSQL equivalent of "Eval"?
I had the same problem. I found this solution:
Declare @SQL as varchar(1000);
SET @SQL = 'DECLARE Transfers_Cursor CURSOR FOR
SELECT * FROM tblTransferWorksheet WHERE Trans_ID IN (' + @Trans_IDs + ')'
EXEC (@SQL)
Fab
-
Or just
exec ('DECLARE Transfers_Cursor CURSOR FOR
SELECT * FROM tblTransferWorksheet WHERE Trans_ID IN (' + @Trans_IDs + ')' )
It's dynamic sql in sql server term.
-
Do you know if SQL that is executed this way using Exec, will count as part of series of Transactions if enclosed within a BEGIN Transaction and Commit/rollback transaction?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|